home *** CD-ROM | disk | FTP | other *** search
- /* Listing3: © Clemens Marschner, 1994
- * demonstriert die Verwendung von Mehrfachvererbung */
-
- #include <stream.h>
-
- class real {
- float wert;
- public:
- real(float w) : wert(w) {}
- float read() { return wert; }
- void write(float w) { wert=w; }
- };
-
- class imag {
- float wert;
- public:
- imag(float w) : wert(w) {}
- float read() { return wert; }
- void write(float w) { wert=w; }
- };
-
- class complex : public real, imag {
- public:
- complex(float r, float i) : real(r), imag(i) {}
- void print();
- };
-
- void complex::print() {
- cout << "(" << real::read() << "," << imag::read() << ")\n";
- // Mehrdeutigkeiten -> Scope-Resolution Operator "::"
- }
-
- void main() {
- complex a(10,1.6);
- cout << "Komplexe Zahl: ";
- a.print();
- }
-
-